var loginUsername = "${loginUsername}"; // 获得当前登录人员的userName
var warehouseUid = 'MM_WIP'; //'${request.getParameter("warehouseUid")}';

var isFinishSetValue = true;

//@Bind #dtInvMonthCheckDetail.onDataChange
!function(self, arg, dsInvMonthCheck, dsInvMonthCheckDetail) {
	if(arg.property=='unitPrice' && isFinishSetValue == true){
		isFinishSetValue = false;
		arg.entity.set("lastTotalAmount", arg.newValue * arg.entity.get("lastInvQty"));
		isFinishSetValue = true;
	}
	if(arg.property=='lastTotalAmount' && isFinishSetValue == true){
		isFinishSetValue = false;
		arg.entity.set("unitPrice", arg.newValue / arg.entity.get("lastInvQty"));
		isFinishSetValue = true;
	}
}

//@Bind view.onReady
!function(self, arg, dsInvMonthCheck, dsInvMonthCheckDetail) {
	dsInvMonthCheck.set("parameter", {
		"warehouseUid": warehouseUid
	});
	dsInvMonthCheck.flush();
	
	monthCheck = dsInvMonthCheck.getData("#");
	if(monthCheck){
		dsInvMonthCheckDetail.set("parameter", {
			"invMonthCheckUid": monthCheck.get("uuid")
		});
		dsInvMonthCheckDetail.flush();
	}
	
}



//@Bind #dpMonthCheckType.beforeExecute
!function(self,arg,dsTypesData) {
	dsTypesData.set("parameter", {typeName: "monthchecktype"});
	dsTypesData.flush();
}

//@Bind #btnCreateDetails.onClick
!function(self,arg,dsInvMonthCheck,dsInvMonthCheckDetail,actionCreateDetails) {
	var monthCheck = dsInvMonthCheck.getData("#");
	alert(monthCheck.get("uuid"));
	actionCreateDetails.set("parameter", {
		invMonthCheckUid: monthCheck.get("uuid")}).execute(function(result){
			dsInvMonthCheckDetail.set("parameter", {
				"invMonthCheckUid": monthCheck.get("uuid")
			});
			dsInvMonthCheckDetail.flush();
	});
	

}